package com.pqc.tbk.web.admin;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import com.pqc.tbk.service.taobao.TaoBaoService;

@Controller
@RequestMapping("/admin")
public class AdminController {

	private TaoBaoService taoBaoService;

	private static final String SESSION = "610210011e86861f1b510e305784dfa355512aae2a210e4720570431";

	@RequestMapping("report")
	public String report(final Model model, final HttpServletRequest request) {

		// final Object obj = request.getSession().getAttribute("top_session");
		// if (obj == null) {
		// return "redirect:/admin/_login";
		// }
		// final String top_session = (String) obj;//
		model.addAttribute("report",
				taoBaoService.getReport("20120712", SESSION));
		return "admin/report";
	}

	@RequestMapping("_{view}")
	public String view(@PathVariable("view") final String view) {
		return "admin/" + view;
	}

	@Autowired
	public void setTaoBaoService(final TaoBaoService taoBaoService) {
		this.taoBaoService = taoBaoService;
	}

}
